package p2Exceptions;

/**
 * ExceptMain3 - Examples of run time errors that result in exceptions
 *  and how to catch them - this time with the Exception inheritance scheme
 * 
 * @author tony
 *
 */
public class ExceptMain3 {
	public static void main(String[] args) {
		double dx = 0;
		System.out.println(" dx is " + dx );
		double dy = 0;
		dy = 1/dx;
		System.out.println(" dy is " + dy );

		try {
			int x = 0;
			System.out.println(" x is " + x );
			int y = 0;
			y = 1/x;
			System.out.println(" y is " + y );

		
			String s = null;
			System.out.println(" s is " + s );
			System.out.println("  and it's length is " + s.length() );
			
		} catch (ArithmeticException ae) {
			System.err.println( "Arithmetic Exception detected");
		} catch (NullPointerException ne){
			System.err.println( "Null Pointer Dereference Exception detected");
		} catch (Exception e){
			System.err.println( "Some Exception detected");			
		} catch (Throwable t){
			System.err.println( "Some Throwable detected");			
		}
	}
}
